package com.api.demo.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.api.demo.entity.ApiLog;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

@Mapper
public interface ApiLogMapper extends BaseMapper<ApiLog> {
    
    @Select("SELECT COUNT(*) FROM sys_api_log")
    Long getTotalCount();
    
    @Select("SELECT path, COUNT(*) as count, AVG(duration) as avgDuration " +
            "FROM sys_api_log GROUP BY path ORDER BY count DESC LIMIT 10")
    List<Map<String, Object>> getTopRequests();

    List<Map<String, Object>> selectMaps(@Param("ew") QueryWrapper<ApiLog> queryWrapper);
}
